<template>
  <div>
    <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/XQzhidingfenpei' }">消缺任务管理 </el-breadcrumb-item>
        <el-breadcrumb-item><a href="/XQchaxun">消缺查询</a></el-breadcrumb-item>
      </el-breadcrumb>



     <router-link to="/XQchaxunTJ">添加</router-link>

<el-table :data="tableData" style="width: 100%">
    <el-table-column label="编号" >
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.findid }}</span>
      </template>
    </el-table-column>

    <el-table-column label="杆塔编号" >
      <template slot-scope="scope">
        <span >{{ scope.row.gtid}}</span>
      </template>
    </el-table-column>
    <el-table-column label="缺陷级别" >
      <template slot-scope="scope">
        <span >{{ scope.row.qxlv}}</span>
      </template>
    </el-table-column>
    <el-table-column label="缺陷类型" >
      <template slot-scope="scope">
        <span >{{ scope.row.qxtype}}</span>
      </template>
    </el-table-column>
    <el-table-column label="发现人" >
      <template slot-scope="scope">
        <span >{{ scope.row.findUser}}</span>
      </template>
    </el-table-column>
    <el-table-column label="发现时间" width="100px"  :formatter="dateFormat" >
      <template slot-scope="scope">
        <span >{{ scope.row.findtime}}</span>
      </template>
    </el-table-column>
    <el-table-column label="任务下发人" >
      <template slot-scope="scope">
        <span >{{ scope.row.xiauser}}</span>
      </template>
    </el-table-column>
    <el-table-column label="下发时间"   :formatter="dateFormat" >
      <template slot-scope="scope">
        <span >{{ scope.row.xiaDate}}</span>
      </template>
    </el-table-column>
    <el-table-column label="完好率" >
      <template slot-scope="scope">
        <!-- parseInt:强制类型转换成int -->
        <el-progress :text-inside="true" :stroke-width="26" :percentage="parseInt(scope.row.rate)"></el-progress>
      </template>
    </el-table-column>

    <el-table-column label="缺陷描述" >
      <template slot-scope="scope">
        <span >{{ scope.row.qxmiaoshu}}</span>
      </template>
    </el-table-column>

    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button type="text" @click="dialogVisible = true">编辑</el-button>
         <el-dialog title="提示" :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
          <span>编辑</span>
          <span slot="footer" class="dialog-footer">
            <el-button @click="dialogVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
          </span>
        </el-dialog>
        <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
  
  <el-pagination @current-change="page" @prev-click="page" @next-click="page" background
  	layout="prev,pager,next,total,jumper" :total="total" :page-size="2"></el-pagination>
</div>
</template>

<script>
  import axios from 'axios';
  export default {
    data() {
      return {
        tableData: [],
         total: 0,
         dialogVisible: false,
         visible:false,

      }
    },
    methods: {
       handleClose(done) {
              this.$confirm('确认关闭？')
                .then(_ => {
                  done();
                })
                .catch(_ => {});
            },
      page: function(curpage) {
                  this.getData(curpage, 2)
      },
      handleEdit(index, row) {
        console.log(index, row);
      },
      handleDelete(index, row) {
        console.log(index, row);
      },
      jia(){
        this.visible=true;
      },

      onSubmit() {
              console.log('submit!');
            },
       dateFormat:function(row,column){
              console.log(row);
              var t=new Date(row.xiaDate);//row 表示一行数据, updateTime 表示要格式化的字段名称
              return t.getFullYear()+"-"+(t.getMonth()+1)+"-"+t.getDate();
       },
       getData: function(curpage, pagesize) {
                   axios.get("/qx/all", {
                    params:{
                      pageNum: curpage,
                      pageSize: pagesize
                    }


                     }).then(vs => {
                       this.tableData=vs.data.list,

                       this.total = vs.data.total,
                       console.log(this.tableData),
                       console.log(this.total);
                     }).catch(err => console.log(err));
                 }
    },
    //新增
    tianjia(){
      this.$axios.post("/qx/insert", {

      })
    },
    created: function() {

              /* axios.get("http://localhost:8085/all")
                  .then(vs => this.options = vs.data,
                     )
                  .catch(err => console.log(err)); */
             this.getData(1, 2)
            },
    /* 页面一加载就自动执行 */
    mounted() {


      /* var self=this
      this.$axios.post("/qx/all")
      .then(function(d){
        self.tableData=d.data
        console.log(d.data)
      }).catch(function(v){
        console.log(v)
      }) */

    }
  }
</script>

<style>
</style>
